import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_pleasure_video/constant/color.dart';

class DebugDialog extends StatelessWidget {
  final Function()? onClickListener;
  final Function()? onExitListener;
  final String textString;

  final List<Widget> _viewList = [];

  DebugDialog(this.textString, {Key? key, this.onClickListener, this.onExitListener}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
      decoration: BoxDecoration(
        color: AppColor.white,
        borderRadius: BorderRadius.circular(7),
      ),
      child: SingleChildScrollView(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: _buildDialogView(context),
        ),
      ),
    );
  }

  List<Widget> _buildDialogView(BuildContext context) {
    _viewList.clear();
    _buildAlertTextView(context);
    return _viewList;
  }

  _buildAlertTextView(BuildContext context) {
    _viewList.add(
      GestureDetector(
        child: Container(
          child: Text(textString),
        ),
        onTap: () {
          Navigator.pop(context);
          if (onClickListener != null) {
            onClickListener!();
          }
          if (onExitListener != null) {
            onExitListener!();
          }
        },
      ),
    );
  }
}
